Skip to content

feat(id): currency status transitions (freeze/sunset) in the registry and gateway service (#13342) - #13547

Merged
dezren39 merged 1 commit into
mainfrom
lane-aaq-13342
Nov 23, 2026
Merged

dezren39 merged 1 commit into
mainfrom
lane-aaq-13342

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Implements #13342: the F1 registry gains a status-transition write and the production gateway service executes freeze/sunset through it.

What changed

Registry (pkgs/id/crates/id-currency-registry)

  • Store::set_currency_status — the transition write on the store seam; InMemoryStore implements it against the currency row (UnknownLedger when no currency row exists for the ledger).
  • Registry::freeze_currency / Registry::sunset_currency over one issuer-only set_status, with the transition table decided and documented in the method docs:
    • Active → Frozen, Active → Sunset, Frozen → Sunset (sunset stays reachable from frozen, so freeze is never a trap short of the terminal state);
    • sunset is terminal — Sunset → Frozen refuses with the new typed RegistryError::InvalidTransition { from, to };
    • repeats (freeze on frozen, sunset on sunset) are idempotent successes, not errors — this is what lets the service answer a retry whose intent finalize was lost after the transition landed.
  • RegistryError::NotIssuer now covers issuer-only writes generally (grant + transitions); its display text is neutral accordingly.

Gateway service (pkgs/id/src/currency/gateway_service.rs)

  • handle() executes Freeze/Sunset (new set_status path) and records each as a posted intent via the same posted_simple shape as registration/grants — no ledger transfer exists to write ahead of; the transition's idempotence is the crash answer.
  • GatewayService::open() replays posted freeze/sunset intents over the rebuilt registry records (all freezes before all sunsets; transitions are monotone), so a status survives restart.
  • The Unsupported arms for freeze/sunset are gone (remaining Unsupported fallback covers reads/convert as before).

F3 authorization (pkgs/id/src/currency/gateway.rs)

  • Freeze/Sunset arms now authorize on existence + issuer only instead of requiring Active — requiring Active would make sunset unreachable from frozen and a repeat freeze unanswerable. Transition legality lives in the registry's table.
  • Value ops unchanged: they still require Active through active_currency, and RegistryView already maps the registry record's status onto the view's active flag — so once a transition lands in the registry, issue/transfer on that currency refuse with InactiveCurrency. Which layer refuses what is documented in the service module docs.

Verification (laptop run, private target dir, sccache disabled)

  • cargo test -p id-currency-registry — 16 acceptance (5 new: happy paths incl. sunset-from-frozen, non-issuer refusal, idempotent repeats, unknown currency, sunset terminal) + 6 factory + 17 grants, all green.
  • cargo test -p id --lib currency — 152 passed, 0 failed (incl. new gateway authorize test and 3 new service tests: execute + value ops refuse; issuer-only + exact-retry replay + fresh-id repeat; restart replay over the durable store).
  • cargo test -p id --lib (full) — 572 passed, 4 failed; the 4 failures are the pre-existing hosted_export failures documented on id: 4 hosted_export tests fail on main (BlobCitationMismatch/MissingBlob) #13444 (BlobCitationMismatch/MissingBlob on main, flag-held), untouched by this change.
  • cargo clippy on both crates — no warnings in the touched files (one pedantic or-pattern warning in the new match was found and fixed; remaining registry warnings are pre-existing in untouched files).
  • rustfmt: touched files carry no new drift vs their pristine-main baseline.

Closes #13342


Proof this PR
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

… and gateway service (#13342)

Registry (id-currency-registry):
- Store::set_currency_status is the status-transition write
  (InMemoryStore implements it against the currency row).
- Registry::freeze_currency / sunset_currency share one
  issuer-only set_status with a documented transition table:
  Active -> Frozen, Active -> Sunset, Frozen -> Sunset
  (sunset stays reachable from frozen); sunset is terminal
  (InvalidTransition); repeats are idempotent successes.
- RegistryError::InvalidTransition names the from/to statuses.

Gateway service (pkgs/id):
- handle() executes Freeze/Sunset through the registry write
  and records each as a posted intent (posted_simple, like
  registration and grants); the transition's idempotence is
  the write-ahead answer for a retry whose intent finalize
  was lost.
- open() replays posted freeze/sunset intents over the
  rebuilt registry records (freezes before sunsets; the
  transitions are monotone), so a status survives restart.
- F3 authorize(): lifecycle ops are authorized on existence
  plus issuer only (they are how a currency leaves Active);
  value ops keep requiring Active, and RegistryView already
  maps the registry status onto the view's active flag, so
  issue/transfer on a frozen or sunset currency refuse with
  InactiveCurrency. Layering documented in the module docs.

Tests: 5 new registry acceptance tests (happy paths,
non-issuer refusal, idempotent repeats, unknown currency,
sunset terminal); a gateway authorize test pinning
lifecycle authorization on an inactive currency; 3 new
gateway-service tests (execute + value ops refuse, issuer-
only + retry/repeat answers, restart replay). The old
unsupported_ops_refuse_by_name test now pins a balance read
instead of freeze/sunset.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 31 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 86a675d0-a50a-4179-bfb4-40270bf715cd
Commits

Reviewing files that changed from the base of the PR and between 2be57cc and a435fa6.

Files selected for processing: 5

  • pkgs/id/crates/id-currency-registry/src/registry.rs
  • pkgs/id/crates/id-currency-registry/src/store.rs
  • pkgs/id/crates/id-currency-registry/tests/acceptance.rs
  • pkgs/id/src/currency/gateway.rs
  • pkgs/id/src/currency/gateway_service.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T18:02:38.813747Z a435fa6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39
dezren39 merged commit cb8c847 into main Nov 23, 2026
2 checks passed
@dezren39
dezren39 deleted the lane-aaq-13342 branch November 23, 2026 18:00

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a435fa68be

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +248 to +249
#[test]
fn issuer_can_freeze_then_sunset_and_sunset_is_terminal() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add generated coverage for the currency lifecycle model

The new lifecycle is a specified state machine with terminal-state, authorization, and idempotence invariants, but its coverage consists solely of hand-written examples. AGENTS.md requires property tests for invariants and model-based tests where a specification exists; the existing gateway property tests do not exercise lifecycle transitions. Add generated issuer/non-issuer freeze/sunset sequences against a three-state reference model, checking terminal-state monotonicity, idempotence, unchanged state after rejection, and equivalence after restart replay.

AGENTS.md reference: AGENTS.md:L37-L39

Useful? React with 👍 / 👎.

/// currency's issuer may move its status — the same
/// issuer-only rule as `grant_minter` (design section 4.2).
///
/// The transition table, decided here:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Record lifecycle decisions in the required dated design document

This adds public lifecycle APIs and decides terminal-sunset, repeat-idempotence, and restart-replay semantics, but records those decisions only in Rust comments. The earlier control-plane design defines the status flags and signed writes, not these transition/recovery choices; a repository-wide documentation search found no corresponding dated record. Add the dated design document required by pkgs/id/AGENTS.md, explaining the transition table and retry/replay rationale, so this behavioral/API change has the required architecture history.

AGENTS.md reference: pkgs/id/AGENTS.md:L159-L168

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

id-currency-registry: add currency status transitions (freeze/sunset) and wire them into the gateway service

1 participant